package com.pure.common.singleton;

/**
 * @description: singleton test
 * @date: 2022-11-09 15:54
 * @since 1.2.0
 **/
public class SingletonTest {

    public static void main(String[] args) {

        System.out.println("单例对象是否是同一对象: " + isEqual(SingletonPattern.getInstance(), SingletonPattern.getInstance()));

        SingletonEnum.INSTANCE.doSomething();


        Student instance1 = SingletonEnum.INSTANCE.getInstance();
        instance1.setAvailableAmount(100D);
        System.out.println(instance1.toString());

        Student instance2 = SingletonEnum.INSTANCE.getInstance();
        instance2.setAvailableAmount(instance2.getAvailableAmount() + 100D);
        System.out.println(instance1 == instance2);
        System.out.println(instance2.toString());
    }

    public static boolean isEqual(SingletonPattern obj1, SingletonPattern obj2) {

        if (obj1 == obj2) {
            return true;
        }
        return false;
    }

}
